#pragma once

class Object
{
public:
	Object() : m_ref(0)
	{

	}

	virtual ~Object()
	{
		
	}

	virtual int addref()
	{
		return ++m_ref;
	}

	virtual int release()
	{
		m_ref--;
		if (0 == m_ref) {
			OnFinalRelease();
			delete this;
		}
		return m_ref;
	}

	virtual void OnFinalRelease()
	{

	}

private:
	int m_ref;
};